package com.aiwei.tdjk.service;

import com.aiwei.tdjk.bean.Pager;
import com.aiwei.tdjk.dto.request.GetGroupRelationPagerRequest;
import com.aiwei.tdjk.entity.GroupRelation;

import java.util.List;
import java.util.Set;

/**
 * Created by yanfeng on 2016/12/13.
 */
public interface GroupRelationService {


    void save(GroupRelation groupRelation);
    /**
     * 根据分组id查询分组关系
     * @param request
     * @return
     */
    Pager<GroupRelation> findAllByGroupId(GetGroupRelationPagerRequest request);

    //@Query("select groupId from GroupRelation where userId=?1 or (startUserId<=?1 and endUserId>=?1))")
    List<Long> findGroupIds(Long userId);

    //@Query("select groupId from GroupRelation where userId=?1 or (startUserId<=?1 and endUserId>=?1) or (organizationId in (?2))")
    List<Long> findGroupIds(Long userId, Set<Long> organizationIds);

    /**
     * 添加组织机构 分组关系
     * @param groupId
     * @param organizationIds
     */
    void appendRelation(Long groupId, Long[] organizationIds);

    /**
     * 查询分组关系
     * @param groupId
     * @param organizationId
     * @return
     */
    GroupRelation getByGroupIdAndOrganizationId(Long groupId, Long organizationId);


    void appendRelation(Long groupId, Long[] userIds, Long[] startUserIds, Long[] endUserIds);

    /**
     * 删除分组关系
     * @param id
     */
    void delete(Long id);

    /**
     * 批量删除分组关系
     * @param ids
     */
    void delete(Long[] ids);

    /**
     * 根据分组名获取该分组下的用户
     *
     * @param groupName
     * @return
     */
    List<Long> getUserIdsByGroupName(String groupName);
    /**
     * 根據組id查找用戶
     */
    List<Long> findUserIdsByGroupId(Long groupId);
    /**
     * 根据用户id查找组Ids
     */
    List<Long> findGroupIdsByUserId(Long userId);

}
